@import '../styles/themes/default';

$radio: 'snake-radio';

.#{$radio} {
  display: inline-block;

  &-button {
    &.#{$radio}-solid {
      .#{$radio}-item {
        &-checked {
          color: #fff;
          background: $brand;
          border-color: $brand;

          &:hover {
            color: #fff;
          }
        }
      }
    }

    &.#{$radio}-large {
      .#{$radio}-item {
        height: 40px;
        font-size: $hd * 16;
        line-height: 38px;
      }
    }

    &.#{$radio}-small {
      .#{$radio}-item {
        height: 24px;
        padding: 0 7px;
        line-height: 22px;
      }
    }

    .#{$radio}-item {
      position: relative;
      display: inline-block;
      height: 32px;
      margin: 0;
      padding: 0 15px;
      color: rgba(0, 0, 0, 0.65);
      line-height: 30px;
      background: #fff;
      border: 1px solid #d9d9d9;
      border-top-width: 1.02px;
      border-left: 0;
      cursor: pointer;
      transition: color 0.3s, background 0.3s, border-color 0.3s;

      &:not(:first-child)::before {
        position: absolute;
        top: 0;
        left: -1px;
        display: block;
        width: 1px;
        height: 100%;
        background-color: #d9d9d9;
        content: '';
      }

      &:first-child {
        border-left: 1px solid #d9d9d9;
        border-radius: 4px 0 0 4px;
      }

      &:last-child {
        border-radius: 0 4px 4px 0;
      }

      &:hover {
        color: $brand;
      }

      &-select {
        display: block;
        width: 0;
        height: 0;
        margin-left: 0;

        &-inner {
          display: none;

          &::after {
            display: none;
          }
        }
      }

      &-checked {
        z-index: 1;
        color: $brand;
        background: #fff;
        border-color: $brand;

        &:first-child {
          border-color: $brand;
        }

        &::before {
          background-color: $brand !important;
        }

        .#{$radio}-item-select {
          &::after {
            display: none;
          }
        }
      }
    }
  }

  &-item {
    font-size: $hd * 14;
    font-variant: tabular-nums;
    line-height: $lineHeight;
    color: rgba(0, 0, 0, 0.65);
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    list-style: none;
    cursor: pointer;
    display: inline-block;

    &:hover {
      .#{$radio}-item-select-inner {
        border-color: $brand;
      }
    }

    &-select {
      font-size: $hd * 14;
      font-variant: tabular-nums;
      color: rgba(0, 0, 0, 0.65);
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      list-style: none;
      white-space: nowrap;
      cursor: pointer;
      outline: none;
      display: inline-block;
      line-height: $lineHeight-1;
      position: relative;
      vertical-align: middle;
      top: -0.09em;

      input {
        position: absolute;
        left: 0;
        z-index: 1;
        cursor: pointer;
        opacity: 0;
        top: 0;
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
      }

      &-inner {
        position: relative;
        top: 0;
        left: 0;
        display: block;
        width: 16px;
        height: 16px;
        border: 1px solid #d9d9d9;
        border-radius: 100px;
        background-color: #fff;
        transition: all 0.3s;
        border-collapse: separate;

        &::after {
          position: absolute;
          width: 8px;
          height: 8px;
          left: 3px;
          top: 3px;
          border-radius: 8px;
          display: table;
          border-top: 0;
          border-left: 0;
          content: ' ';
          background-color: $brand;
          opacity: 0;
          transform: scale(0);
          transition: 0.3s $easeInOutCirc;
        }
      }
    }

    &-label {
      padding: 0 8px;
    }

    &-checked {
      .#{$radio}-item-select-inner {
        border-color: $brand;

        &::after {
          transform: scale(0.875);
          opacity: 1;
          transition: all 0.3s $easeInOutCirc;
        }
      }

      .#{$radio}-item-select {
        &::after {
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          border-radius: 2px;
          border: 1px solid $brand;
          content: '';
          animation: antCheckboxEffect 0.36s ease-in-out;
          animation-fill-mode: both;
          visibility: hidden;
        }
      }
    }

    &-disabled {
      cursor: not-allowed;

      .#{$radio}-item-select {
        cursor: not-allowed;
      }

      .#{$radio}-item-select-inner {
        border-color: #d9d9d9 !important;
        background-color: #f5f5f5;

        &::after {
          background-color: rgba(0, 0, 0, 0.2);
        }
      }
    }
  }

  input[type='radio'][disabled] {
    cursor: not-allowed;
  }
}
